﻿
@{
    ViewData["Title"] = "登录";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <title>YdmCore -SignalR</title>
    <script type="text/javascript" src="~/lib/YdmJUI/static/plugins/jquery/jquery.min.js"></script>
    <script src="~/lib/abp-web-resources/abp.js"></script>
    <script src="~/lib/abp-web-resources/signalr-client/signalr.min.js"></script>
    <script src="~/lib/abp-web-resources/libs/abp.signalr-client.js"></script>
    <script type="text/javascript">
        abp.signalr = abp.signalr || {};
        abp.signalr.autoConnect = false;
        $(function myfunction() {
            var chatHub = null;

            abp.signalr.startConnection(abp.appPath + 'signalr-myChatHub', function (connection) {
                chatHub = connection; // Save a reference to the hub
                connection.on('getMessage', function (message) { // Register for incoming messages
                    console.log('received message: ' + message);
                });
            }).then(function (connection) {
                console.log('DisConnected');
                abp.event.trigger('myChatHub.connected');
            });

            abp.event.on('myChatHub.connected', function () { // Register for connect event
                chatHub.invoke('sendMessage', "Hi everybody, I'm connected to the chat!"); // Send a message to the server
            });
        })

    </script>
</head>

</html>
